package com.gxa.controller.ly.drugManagement;

import com.gxa.common.R;
import com.gxa.entity.SysDrugType;
import com.gxa.service.SysDrugTypeService;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@Api(value = "药品类型" ,tags = "药品类型接口API")
@RequestMapping("/drugManagement/drugManagement")
@RequiresRoles(value = {"超级管理员","院长","主任","秘书"},logical = Logical.OR)
public class DrugTypeController {

    @Autowired
    SysDrugTypeService service;

    /**
     * 查找所有药品分类
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/findDrugTypeList",method = RequestMethod.GET)
    @ApiOperation(value = "查找所有药品类型接口",notes = "查找药品类型",httpMethod = "GET", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=400,message="参数错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R findDrugTypeList(){

        R r = service.findDrugTypeList();
        return r;
    }

    /**
     * 修改药品分类信息
     * @param sysDrugType
     * @return
     */
    @RequestMapping(value = "/updateDrugType",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "更新药品类型接口",notes = "更新药品类型",httpMethod = "POST", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=400,message="参数错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R updateDrugType(@RequestBody @ApiParam(name = "sysDrugType",value = "药品对象类型",required = true) SysDrugType sysDrugType){
        return service.updateDrugType(sysDrugType);
    }

    /**
     * 用于修改药品分类回显
     * @param
     * @return
     */
    @RequestMapping(value = "/findDrugTypeById",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "更新药品类型接口",notes = "更新药品类型",httpMethod = "GET", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=400,message="参数错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ApiImplicitParam(name = "id", value = "药品分类id", paramType = "query", dataType = "String", required = true)
    public R findDrugTypeById(Integer id){
        return service.findDrugTypeById(id);
    }


    /**
     * 添加药品分类
     * @param sysDrugType
     * @return
     */
    @RequestMapping(value = "addDrugType",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "添加药品类型接口",notes = "添加药品类型",httpMethod = "POST", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=400,message="参数错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R addDrugType(@RequestBody @ApiParam(name = "sysDrugType",value = "药品对象",required = true) SysDrugType sysDrugType){

        return service.addDrugType(sysDrugType);
    }

    /**
     * 删除药品分类
     * @param id
     * @return
     */
    @RequestMapping(value = "/delDrugType",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "删除药品类型接口",notes = "删除药品类型",httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "药品类型",paramType = "query",dataType = "String",required = true)
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=400,message="参数错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R delDrugType(Integer id){
        return service.delDrugType(id);
    }
}
